package com.wy17113.model.service.impl;

import java.sql.SQLException;
import java.util.List;

import com.wy17113.model.dao.IJokDao;
import com.wy17113.model.entity.Comment;
import com.wy17113.model.entity.Jok;
import com.wy17113.model.service.IJokService;

public class JokServiceImpl implements IJokService {

	private IJokDao jokDao;
	
	public IJokDao getJokDao() {
		return jokDao;
	}

	public void setJokDao(IJokDao jokDao) {
		this.jokDao = jokDao;
	}

	public void delete(String id) throws SQLException {
		jokDao.delete(id);
	}

	public List<Jok> getAllJok(int type, String startTime, String endTime,
			int start, int count) throws SQLException {
		List<Jok> joks = jokDao.getAllJok(type, startTime, endTime, start, count);
		for(Jok jok : joks){
			jok.setJokComCounts(jokDao.getCommentCountssByJokId(jok.getId()));
		}
		return joks;
	}

	public int getAllJokCounts(int type, String startTime, String endTime) {
		return jokDao.getAllJokCounts(type, startTime, endTime);
	}

	public void saveJok(Jok jok) throws SQLException {
		jokDao.saveJok(jok);
	}

	public void updateJokDC(int flag, String id) throws SQLException {
		jokDao.updateJokDC(flag, id);
	}

	public int getJokState(int flag, String id) throws SQLException {
		return jokDao.getJokState(flag, id);
	}

	public void addComment(Comment com) throws SQLException {
		jokDao.addComment(com);
	}

	public int getAllCommentCounts(int flag) {
		return jokDao.getAllCommentCounts(flag);
	}

	public List<Comment> getAllComments(int flag, int start, int count) {
		return jokDao.getAllComments(flag, start, count);
	}

	public void doDel(String comId) throws SQLException {
		jokDao.doDel(comId);
	}

	public void doOperate(int flag, String comId) throws SQLException {
		jokDao.doOperate(flag, comId);
	}

	public Jok getJokById(String id) {
		return jokDao.getJokById(id);
	}

	public void updateJok(Jok jok) {
		jokDao.updateJok(jok);
	}

}
